package com.zcm.service.weibo.load.impl;

import net.sf.json.JSONObject;

import org.springframework.social.connect.Connection;
import org.springframework.social.oauth1.OAuthToken;

import com.zcm.service.auth.impl.AccessToken;
import com.zcm.service.support.ConnectionFacoryRegistryUtil;
import com.zcm.service.weibo.load.UserLoadOperators;
import com.zcm.service.weibo.serviceprovider.sina.api.SinaWeibo;
import com.zcm.service.weibo.serviceprovider.sina.api.UserOperations;
import com.zcm.service.weibo.serviceprovider.sina.api.model.SinaWeiboProfile;
import com.zcm.service.weibo.serviceprovider.sina.connect.SinaWeiboConnectionFactory;


public class UserLoadOperatorImpl implements UserLoadOperators {
	
	
	
	
	public UserLoadOperatorImpl() {}
	
	public JSONObject loadUserCounts(String uids) {
		return null;
	}

	public JSONObject loadUserInfo(String uid, AccessToken accessToken) {
		SinaWeiboConnectionFactory sinaWeiboConnectionFactory = ConnectionFacoryRegistryUtil.getSinaConnectionFactory();
		OAuthToken accessOauthToken = new OAuthToken(accessToken.getAccessToken(), accessToken.getSecret());
		Connection<SinaWeibo> sinaConnetion = sinaWeiboConnectionFactory.createConnection(accessOauthToken);	
		SinaWeibo sinaWeiboApi = sinaConnetion.getApi();
		UserOperations userOperations = sinaWeiboApi.userOperations();
		SinaWeiboProfile  sinaWbUserInfo = userOperations.getUserProfile(accessToken.getScreenName());
		System.out.println(sinaWbUserInfo.getId());
		return null;
	}
}
